package com.ustc.hewei.consumerweb;

import com.ustc.hewei.commons.TestDemo;
import com.ustc.hewei.commons.TestDemo2;
import com.ustc.hewei.rpc.annotation.InjectService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
* @description: TODO
* @author hewei
* @date 2022/7/28 22:07
* @version 1.0
*/
@RestController
public class TestConsumer {
    @InjectService
    private TestDemo testDemo;

    @InjectService
    private TestDemo2 testDemo2;

    @GetMapping("/add/{param1}/{param2}")
    public String add(@PathVariable("param1") int a, @PathVariable("param2") int b) {
        return String.valueOf(testDemo.add(a, b));
    }

    @GetMapping("/divide/{param1}/{param2}")
    public String divide(@PathVariable("param1") int a, @PathVariable("param2") int b) {
        return String.valueOf(testDemo2.divide(a, b));
    }

    @GetMapping("/minus/{param1}/{param2}")
    public String minus(@PathVariable("param1") int a, @PathVariable("param2") int b) {
        return String.valueOf(testDemo.minus(a, b));
    }

    @GetMapping("/multiply/{param1}/{param2}")
    public String multiply(@PathVariable("param1") int a, @PathVariable("param2") int b) {
        return String.valueOf(testDemo2.multiply(a, b));
    }
}
